How to assign the minimum or maximum value of a data type?

If you want to assign the minimum value (= the lower limit) or the maximum value (= the upper limit) of particular →data types, use the terms MIN or MAX. Bear in mind to prefix the term with the type (e.g. INT) and the character #.

This possibility is provided as enhancement to the →IEC-standard and is supported for the following data types:

  • REALLREALUSINTUINTUDINTULINTSINTINTDINT or LINT
    (corresponds to →generic data type ANY_NUM

  • BYTEWORDDWORD or LWORD(corresponds to →generic data type ANY_BIT without BOOL

See "Supported data types (in ST)" about all lower/upper limits of the data types.

Example
PROGRAM Test
  VAR
    VarInt : INT;
    VarWord: WORD;
  END_VAR
    
  VarInt := INT#MIN;    (* The variable 'VarInt' gets the value '-32768' which is the lower limit of data type 'INT'. *)
  VarWord := WORD#MAX;  (* The variable 'VarWord' gets the value '16#FFFF' (decimal: '65535') which is the upper limit of data type 'WORD'. *)
END_PROGRAM